package cn.hx.mall_goods;

public class CounterDemo {
    public long timeStamp = getNowTime();
    public int reqCount = 0;
    public final int limit = 10000;
    long interval = 1000;

    public boolean grant() {
        long now = getNowTime();
        if (now < timeStamp + interval) {
            reqCount++;
            return reqCount <= limit;
        }
        timeStamp = now;
        reqCount = 1;
        return true;
    }

    static Long getNowTime() {
        return System.currentTimeMillis();
    }
}